package com.hktf.moedokilock.page;

import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.FragmentActivity;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.hktf.corelib.callback.GetDataCallBack;
import com.hktf.corelib.jsonbean.YaoQingRecord;
import com.hktf.corelib.jsonbean.response.YaoQingRecordResult;
import com.hktf.moedokilock.adapter.YaoQingRecordAdapter;
import com.hktf.uilib.base.BaseListPage;
import com.hktf.uilib.callback.BaseCallBackNew;
import com.hktf.uilib.engine.DriverEngine;
import com.hktf.uilib.utils.DlgUtils;
import com.lzy.okgo.model.Response;

import java.util.List;

/**
 * @author 陈大专
 * @time 2025/6/11 16:56
 * @des
 **/
public class YaoQingRecordPage extends BaseListPage<YaoQingRecord> implements BaseQuickAdapter.OnItemClickListener, BaseQuickAdapter.OnItemChildClickListener {


    public YaoQingRecordPage(FragmentActivity context) {
        super(context);
    }

    @Override
    public BaseQuickAdapter getAdapter(List<YaoQingRecord> list) {
        YaoQingRecordAdapter siteItemAdapter = new YaoQingRecordAdapter(list);
        siteItemAdapter.setOnItemClickListener(this);
        siteItemAdapter.setOnItemChildClickListener(this);
        return siteItemAdapter;
    }

    public void setRootView(ViewGroup container) {
        container.addView(getRootView());
        if (adapter != null) {
            adapter.getData().clear();
        }
        showPage();
    }

    @Override
    public void getData(GetDataCallBack<YaoQingRecord> callBack) {
        DriverEngine.yaoqingList(new BaseCallBackNew<YaoQingRecordResult>(YaoQingRecordResult.class) {
            @Override
            public void onSUCCESS(Response<YaoQingRecordResult> response) {
                DlgUtils.disMissDlg();
                YaoQingRecordResult body = response.body();
                List<YaoQingRecord> data = body.getData();
                callBack.onSuccess(data);
            }
            @Override
            public void onError(Response<YaoQingRecordResult> response) {
                callBack.onError();
            }

            @Override
            public void onResponseFail(String msg, String errorcode) {
                callBack.onError();
            }
        });
    }



//    @Override
//    public View createEmptyView() {
//        View view = View.inflate(CommUtils.getContext(),
//                R.layout.YaoQingRecord_list_empty_layout, null);
//        return view;
//    }


    @Override
    public void onItemClick(BaseQuickAdapter adapter1, View view, int position) {

    }
    private boolean isDestroy;

    public void onDestroy(){
        isDestroy=true;
        context=null;
    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter1, View view, int position) {

    }

}
